﻿using System;
using System.Collections.Generic;
using System.Text;

using RaisingStudio.Data;
using RaisingStudio.Data.Common;
using RaisingStudio.Data.Expressions;
using RaisingStudio.Data.Common.Managers;
using RaisingStudio.Data.Providers.Exceptions;
using System.Data;

namespace RaisingStudio.Data.Providers.Adapters.Generic
{
    /// <summary>
    /// data object adapter generic.
    /// </summary>
    public class DataObjectAdapter<T>
    {
        #region Common property 
        protected RaisingStudio.Data.Providers.Adapters.DataObjectAdapter adapter;
        /// <summary>
        /// data object DataAdapter.
        /// </summary>
        public RaisingStudio.Data.Providers.Adapters.DataObjectAdapter Adapter
        {
            get
            {
                return this.adapter;
            }
        }

        /// <summary>
        /// data Type of data object.
        /// </summary>
        public System.Type DataObjectType
        {
            get
            {
                return Adapter.DataObjectType;
            }
        }

        /// <summary>
        /// database connection.
        /// </summary>
        public System.Data.IDbConnection Connection
        {
            get
            {
                return Adapter.Connection;
            }
        }

        /// <summary>
        /// database transaction manager.
        /// </summary>
        public TransactionManager TransactionManager
        {
            get
            {
                return Adapter.TransactionManager;
            }
        }

        /// <summary>
        /// Command builder.
        /// </summary>
        public RaisingStudio.Data.Common.Builders.CommandBuilder CommandBuilder
        {
            get
            {
                return Adapter.CommandBuilder;
            }
        }

        /// <summary>
        /// default Data table mapping.
        /// </summary>
        public System.Data.Common.DataTableMapping DefaultDataTableMapping
        {
            get
            {
                return Adapter.DefaultDataTableMapping;
            }
        }
        #endregion

        #region Constructor
        public DataObjectAdapter(DataObjectAdapter adapter)
        {
            this.adapter = adapter;
        }

       /// <summary>
        /// Constructor
        /// </summary>
        public DataObjectAdapter()
        {
            this.adapter = new DataObjectAdapter(typeof(T));
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="connection">database connection.</param>
        public DataObjectAdapter(System.Data.IDbConnection connection)
        {
            this.adapter = new DataObjectAdapter(typeof(T), connection);
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="transactionManager">database transaction manager.</param>
        public DataObjectAdapter(TransactionManager transactionManager, ILogManager logManager)
        {
            this.adapter = new DataObjectAdapter(typeof(T), transactionManager, logManager);
        }
   
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="definitionName">object definition name.</param>
        public DataObjectAdapter(string definitionName)
        {
            this.adapter = new DataObjectAdapter(typeof(T), definitionName);
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="definitionName">object definition name.</param>
        /// <param name="connection">database connection.</param>
        public DataObjectAdapter(string definitionName, System.Data.IDbConnection connection)
        {
            this.adapter = new DataObjectAdapter(typeof(T), definitionName, connection);
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="definitionName">object definition name.</param>
        /// <param name="transactionManager">database transaction manager.</param>
        public DataObjectAdapter(string definitionName, TransactionManager transactionManager, ILogManager logManager)
        {
            this.adapter = new DataObjectAdapter(typeof(T), definitionName, transactionManager, logManager);
        }
        #endregion

        #region Transactions
        /// <summary>
        /// Begin Database transaction.
        /// </summary>
        /// <returns>The ID of transaction.</returns>
        public virtual string BeginTransaction()
        {
            return this.adapter.BeginTransaction();
        }

        /// <summary>
        /// Begin Database transaction.
        /// </summary>
        /// <param name="isolationLevel">Specifies the isolation level for the transaction.</param>
        /// <returns>The ID of transaction.</returns>
        public virtual string BeginTransaction(System.Data.IsolationLevel isolationLevel)
        {
            return this.adapter.BeginTransaction(isolationLevel);
        }

        /// <summary>
        /// Commit Database transaction.
        /// </summary>
        public virtual void CommitTransaction()
        {
            this.adapter.CommitTransaction();
        }

        /// <summary>
        /// Commit Database transaction.
        /// </summary>
        /// <param name="transactionID">The ID of transaction.</param>
        public virtual void CommitTransaction(string transactionID)
        {
            this.adapter.CommitTransaction(transactionID);
        }

        /// <summary>
        /// Rollback transaction.
        /// </summary>
        public virtual void RollbackTransaction()
        {
            this.adapter.RollbackTransaction();
        }

        /// <summary>
        /// Rollback transaction.
        /// </summary>
        /// <param name="transactionID">The ID of transaction.</param>
        public virtual void RollbackTransaction(string transactionID)
        {
            this.adapter.RollbackTransaction(transactionID);
        }
        #endregion
        
        #region Common Methods
        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int Fill(object dataObject, object[] primaryKeys)
        {
            return this.adapter.Fill(dataObject, primaryKeys);
        }

        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">has primary key value Data object.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int Fill(object dataObject)
        {
            return this.adapter.Fill(dataObject);
        }

        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int Fill(object dataObject, object[] primaryKeys, string[] columnNames)
        {
            return this.adapter.Fill(dataObject, primaryKeys, columnNames);
        }

        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">has primary key value Data object.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int Fill(object dataObject, string[] columnNames)
        {
            return this.adapter.Fill(dataObject, columnNames);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <returns>Data object.</returns>
        public virtual T GetData(object[] primaryKeys)
        {
            return (T)this.adapter.GetData(primaryKeys);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="dataObject">has primary key value Data object.</param>
        /// <returns>Data object.</returns>
        public virtual T GetData(object dataObject)
        {
            return (T)this.adapter.GetData(dataObject);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>Data object.</returns>
        public virtual T GetData(object[] primaryKeys, string[] columnNames)
        {
            return (T)this.adapter.GetData(primaryKeys, columnNames);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="dataObject">has primary key value Data object.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>Data object.</returns>
        public virtual T GetData(object dataObject, string[] columnNames)
        {
            return (T)this.adapter.GetData(dataObject, columnNames);
        }

        /// <summary>
        /// Insert Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Insert(object dataObject)
        {
            return this.adapter.Insert(dataObject);
        }

        /// <summary>
        /// Insert Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Insert(object dataObject, string[] columnNames)
        {
            return this.adapter.Insert(dataObject, columnNames);
        }

        /// <summary>
        /// Delete Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(object dataObject)
        {
            return this.adapter.Delete(dataObject);
        }

        /// <summary>
        /// Delete Data object.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(object[] primaryKeys)
        {
            return this.adapter.Delete(primaryKeys);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object dataObject)
        {
            return this.adapter.Update(dataObject);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="dataObject">Data object.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] primaryKeys, object dataObject)
        {
            return this.adapter.Update(primaryKeys, dataObject);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object dataObject, string[] columnNames)
        {
            return this.adapter.Update(dataObject, columnNames);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] primaryKeys, object dataObject, string[] columnNames)
        {
            return this.adapter.Update(primaryKeys, dataObject, columnNames);
        }

        /// <summary>
        /// Check data object by primary key.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <returns>If exists then return true, otherwise return false.</returns>
        public virtual bool Exists(object dataObject)
        {
            return this.adapter.Exists(dataObject);
        }

        /// <summary>
        /// Check data object by primary key.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <returns>If exists then return true, otherwise return false.</returns>
        public virtual bool Exists(object[] primaryKeys)
        {
            return this.adapter.Exists(primaryKeys);
        }

        /// <summary>
        /// Save Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Save(object dataObject)
        {
            return this.adapter.Save(dataObject);
        }

        /// <summary>
        /// Save Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Save(object dataObject, string[] columnNames)
        {
            return this.adapter.Save(dataObject, columnNames);
        }

        #region Batch Operation 
        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList()
        {
            return (List<T>)this.adapter.GetDataList();
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(string[] columnNames)
        {
            return (List<T>)this.adapter.GetDataList(columnNames);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(CommonCommand conditionCommand)
        {
            return (List<T>)this.adapter.GetDataList(conditionCommand);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(string[] columnNames, CommonCommand conditionCommand)
        {
            return (List<T>)this.adapter.GetDataList(columnNames, conditionCommand);
        }

        #region Paging Operation 
        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(int startRecord, int maxRecords)
        {
            return (List<T>)this.adapter.GetDataList(startRecord, maxRecords);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(string[] columnNames, int startRecord, int maxRecords)
        {
            return (List<T>)this.adapter.GetDataList(columnNames, startRecord, maxRecords);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(CommonCommand conditionCommand, int startRecord, int maxRecords)
        {
            return (List<T>)this.adapter.GetDataList(conditionCommand, startRecord, maxRecords);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords)
        {
            return (List<T>)this.adapter.GetDataList(columnNames, conditionCommand, startRecord, maxRecords);
        }
        #endregion

        #region Enumerator
        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator()
        {
            foreach (object dataObject in this.adapter.GetEnumerator())
            {
                yield return (T)dataObject;
            }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(string[] columnNames)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnNames)) { yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(CommonCommand conditionCommand)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(conditionCommand)){ yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(string[] columnNames, CommonCommand conditionCommand)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnNames, conditionCommand)){ yield return (T)dataObject; }
        }

        #region Paging Operation 
        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(int startRecord, int maxRecords)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(startRecord, maxRecords)){ yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(string[] columnNames, int startRecord, int maxRecords)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnNames, startRecord, maxRecords)){ yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(CommonCommand conditionCommand, int startRecord, int maxRecords)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(conditionCommand, startRecord, maxRecords)){ yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnNames, conditionCommand, startRecord, maxRecords)){ yield return (T)dataObject; }
        }
        #endregion
        #endregion
        #endregion
        #endregion
        #region Transaction
        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int Fill(object dataObject, object[] primaryKeys, string transactionID)
        {
            return this.adapter.Fill(dataObject, primaryKeys, transactionID);
        }

        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">has primary key value Data object.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int Fill(object dataObject, string transactionID)
        {
            return this.adapter.Fill(dataObject, transactionID);
        }

        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int Fill(object dataObject, object[] primaryKeys, string[] columnNames, string transactionID)
        {
            return this.adapter.Fill(dataObject, primaryKeys, columnNames, transactionID);
        }

        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">has primary key value Data object.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int Fill(object dataObject, string[] columnNames, string transactionID)
        {
            return this.adapter.Fill(dataObject, columnNames, transactionID);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Data object.</returns>
        public virtual T GetData(object[] primaryKeys, string transactionID)
        {
            return (T)this.adapter.GetData(primaryKeys, transactionID);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="dataObject">has primary key value Data object.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Data object.</returns>
        public virtual T GetData(object dataObject, string transactionID)
        {
            return (T)this.adapter.GetData(dataObject, transactionID);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Data object.</returns>
        public virtual T GetData(object[] primaryKeys, string[] columnNames, string transactionID)
        {
            return (T)this.adapter.GetData(primaryKeys, columnNames, transactionID);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="dataObject">has primary key value Data object.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Data object.</returns>
        public virtual T GetData(object dataObject, string[] columnNames, string transactionID)
        {
            return (T)this.adapter.GetData(dataObject, columnNames, transactionID);
        }

        /// <summary>
        /// Insert Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Insert(object dataObject, string transactionID)
        {
            return this.adapter.Insert(dataObject, transactionID);
        }

        /// <summary>
        /// Insert Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Insert(object dataObject, string[] columnNames, string transactionID)
        {
            return this.adapter.Insert(dataObject, columnNames, transactionID);
        }

        /// <summary>
        /// Delete Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(object dataObject, string transactionID)
        {
            return this.adapter.Delete(dataObject, transactionID);
        }

        /// <summary>
        /// Delete Data object.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(object[] primaryKeys, string transactionID)
        {
            return this.adapter.Delete(primaryKeys, transactionID);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object dataObject, string transactionID)
        {
            return this.adapter.Update(dataObject, transactionID);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="dataObject">Data object.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] primaryKeys, object dataObject, string transactionID)
        {
            return this.adapter.Update(primaryKeys, dataObject, transactionID);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object dataObject, string[] columnNames, string transactionID)
        {
            return this.adapter.Update(dataObject, columnNames, transactionID);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] primaryKeys, object dataObject, string[] columnNames, string transactionID)
        {
            return this.adapter.Update(primaryKeys, dataObject, columnNames, transactionID);
        }

        /// <summary>
        /// Check data object by primary key.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>If exists then return true, otherwise return false.</returns>
        public virtual bool Exists(object dataObject, string transactionID)
        {
            return this.adapter.Exists(dataObject, transactionID);
        }

        /// <summary>
        /// Check data object by primary key.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>If exists then return true, otherwise return false.</returns>
        public virtual bool Exists(object[] primaryKeys, string transactionID)
        {
            return this.adapter.Exists(primaryKeys, transactionID);
        }

        /// <summary>
        /// Save Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Save(object dataObject, string transactionID)
        {
            return this.adapter.Save(dataObject, transactionID);
        }

        /// <summary>
        /// Save Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Save(object dataObject, string[] columnNames, string transactionID)
        {
            return this.adapter.Save(dataObject, columnNames, transactionID);
        }

        #region Batch Operation 
        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(transactionID);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(string[] columnNames, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(columnNames, transactionID);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(CommonCommand conditionCommand, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(conditionCommand, transactionID);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(string[] columnNames, CommonCommand conditionCommand, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(columnNames, conditionCommand, transactionID);
        }

        #region Paging Operation 
        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(int startRecord, int maxRecords, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(startRecord, maxRecords, transactionID);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(string[] columnNames, int startRecord, int maxRecords, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(columnNames, startRecord, maxRecords, transactionID);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(CommonCommand conditionCommand, int startRecord, int maxRecords, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(conditionCommand, startRecord, maxRecords, transactionID);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(columnNames, conditionCommand, startRecord, maxRecords, transactionID);
        }
        #endregion

        #region Enumerator
        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(transactionID)){ yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(string[] columnNames, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnNames, transactionID)){ yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(CommonCommand conditionCommand, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(conditionCommand, transactionID)){ yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(string[] columnNames, CommonCommand conditionCommand, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnNames, conditionCommand, transactionID)){ yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(int startRecord, int maxRecords, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(startRecord, maxRecords, transactionID)){ yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(string[] columnNames, int startRecord, int maxRecords, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnNames, startRecord, maxRecords, transactionID)){ yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(CommonCommand conditionCommand, int startRecord, int maxRecords, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(conditionCommand, startRecord, maxRecords, transactionID)){ yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnNames, conditionCommand, startRecord, maxRecords, transactionID)){ yield return (T)dataObject; }
        }
        #endregion
        #endregion
        #endregion

        #region Extension Functions
        #region Common Methods
        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int FillByPrimaryKey(object dataObject, object primaryKey)
        {
            return this.adapter.FillByPrimaryKey(dataObject, primaryKey);
        }

        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int FillByPrimaryKey(object dataObject, object primaryKey, string[] columnNames)
        {
            return this.adapter.FillByPrimaryKey(dataObject, primaryKey, columnNames);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <returns>Data object.</returns>
        public virtual T GetDataByPrimaryKey(object primaryKey)
        {
            return (T)this.adapter.GetDataByPrimaryKey(primaryKey);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>Data object.</returns>
        public virtual T GetDataByPrimaryKey(object primaryKey, string[] columnNames)
        {
            return (T)this.adapter.GetDataByPrimaryKey(primaryKey, columnNames);
        }

        /// <summary>
        /// Delete Data object.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int DeleteByPrimaryKey(object primaryKey)
        {
            return this.adapter.DeleteByPrimaryKey(primaryKey);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="dataObject">Data object.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateByPrimaryKey(object primaryKey, object dataObject)
        {
            return this.adapter.UpdateByPrimaryKey(primaryKey, dataObject);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateByPrimaryKey(object primaryKey, object dataObject, string[] columnNames)
        {
            return this.adapter.UpdateByPrimaryKey(primaryKey, dataObject, columnNames);
        }

        /// <summary>
        /// Check data object by primary key.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <returns>If exists then return true, otherwise return false.</returns>
        public virtual bool ExistsByPrimaryKey(object primaryKey)
        {
            return this.adapter.ExistsByPrimaryKey(primaryKey);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>Data object.</returns>
        public virtual T GetDataByCondition(CommonCommand conditionCommand)
        {
            return (T)this.adapter.GetDataByCondition(conditionCommand);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>Data object.</returns>
        public virtual T GetDataByCondition(string[] columnNames, CommonCommand conditionCommand)
        {
            return (T)this.adapter.GetDataByCondition(columnNames, conditionCommand);
        }

        #region Epxression 
        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>Data object.</returns>
        public virtual T GetDataByCondition(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            return (T)this.adapter.GetDataByCondition(conditionExpression);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>Data object.</returns>
        public virtual T GetDataByCondition(string[] columnNames, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            return (T)this.adapter.GetDataByCondition(columnNames, conditionExpression);
        }

        #region Batch Operation 
        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            return (List<T>)this.adapter.GetDataList(conditionExpression);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(string[] columnNames, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            return (List<T>)this.adapter.GetDataList(columnNames, conditionExpression);
        }

        #region Paging Operation 
        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, int startRecord, int maxRecords)
        {
            return (List<T>)this.adapter.GetDataList(conditionExpression, startRecord, maxRecords);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(string[] columnNames, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, int startRecord, int maxRecords)
        {
            return (List<T>)this.adapter.GetDataList(columnNames, conditionExpression, startRecord, maxRecords);
        }
        #endregion

        #region Enumerator
        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(conditionExpression)) { yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(string[] columnNames, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnNames, conditionExpression)) { yield return (T)dataObject; }
        }

        #region Paging Operation 
        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, int startRecord, int maxRecords)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(conditionExpression, startRecord, maxRecords)) { yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(string[] columnNames, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, int startRecord, int maxRecords)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnNames, conditionExpression, startRecord, maxRecords)) { yield return (T)dataObject; }
        }
        #endregion
        #endregion
        #endregion

        #region column name Epxression 
        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int Fill(object dataObject, object[] primaryKeys, ColumnExpression[] columnExpressions)
        {
            return this.adapter.Fill(dataObject, primaryKeys, columnExpressions);
        }

        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">has primary key value Data object.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int Fill(object dataObject, ColumnExpression[] columnExpressions)
        {
            return this.adapter.Fill(dataObject, columnExpressions);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>Data object.</returns>
        public virtual T GetData(object[] primaryKeys, ColumnExpression[] columnExpressions)
        {
            return (T)this.adapter.GetData(primaryKeys, columnExpressions);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="dataObject">has primary key value Data object.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>Data object.</returns>
        public virtual T GetData(object dataObject, ColumnExpression[] columnExpressions)
        {
            return (T)this.adapter.GetData(dataObject, columnExpressions);
        }

        /// <summary>
        /// Insert Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Insert(object dataObject, ColumnExpression[] columnExpressions)
        {
            return this.adapter.Insert(dataObject, columnExpressions);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object dataObject, ColumnExpression[] columnExpressions)
        {
            return this.adapter.Update(dataObject, columnExpressions);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] primaryKeys, object dataObject, ColumnExpression[] columnExpressions)
        {
            return this.adapter.Update(primaryKeys, dataObject, columnExpressions);
        }

        /// <summary>
        /// Save Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Save(object dataObject, ColumnExpression[] columnExpressions)
        {
            return this.adapter.Save(dataObject, columnExpressions);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(ColumnExpression[] columnExpressions)
        {
            return (List<T>)this.adapter.GetDataList(columnExpressions);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(ColumnExpression[] columnExpressions, int startRecord, int maxRecords)
        {
            return (List<T>)this.adapter.GetDataList(columnExpressions, startRecord, maxRecords);
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(ColumnExpression[] columnExpressions)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnExpressions)) { yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(ColumnExpression[] columnExpressions, int startRecord, int maxRecords)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnExpressions, startRecord, maxRecords)) { yield return (T)dataObject; }
        }

        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int FillByPrimaryKey(object dataObject, object primaryKey, ColumnExpression[] columnExpressions)
        {
            return this.adapter.Fill(dataObject, new object[] { primaryKey }, columnExpressions);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>Data object.</returns>
        public virtual T GetDataByPrimaryKey(object primaryKey, ColumnExpression[] columnExpressions)
        {
            return (T)this.adapter.GetData(new object[] { primaryKey }, columnExpressions);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateByPrimaryKey(object primaryKey, object dataObject, ColumnExpression[] columnExpressions)
        {
            return this.adapter.Update(new object[] { primaryKey }, dataObject, columnExpressions);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>Data object.</returns>
        public virtual T GetDataByCondition(ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            return (T)this.adapter.GetDataByCondition(columnExpressions, conditionExpression);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            return (List<T>)this.adapter.GetDataList(columnExpressions, conditionExpression);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, int startRecord, int maxRecords)
        {
            return (List<T>)this.adapter.GetDataList(columnExpressions, conditionExpression, startRecord, maxRecords);
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnExpressions, conditionExpression)) { yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, int startRecord, int maxRecords)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnExpressions, conditionExpression, startRecord, maxRecords)) { yield return (T)dataObject; }
        }
        #endregion
        #endregion
        #endregion
        #region Transaction
        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int FillByPrimaryKey(object dataObject, object primaryKey, string transactionID)
        {
            return this.adapter.FillByPrimaryKey(dataObject, primaryKey, transactionID);
        }

        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int FillByPrimaryKey(object dataObject, object primaryKey, string[] columnNames, string transactionID)
        {
            return this.adapter.FillByPrimaryKey(dataObject, primaryKey, columnNames, transactionID);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Data object.</returns>
        public virtual object GetDataByPrimaryKey(object primaryKey, string transactionID)
        {
            return this.adapter.GetDataByPrimaryKey(primaryKey, transactionID);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Data object.</returns>
        public virtual T GetDataByPrimaryKey(object primaryKey, string[] columnNames, string transactionID)
        {
            return (T)this.adapter.GetDataByPrimaryKey(primaryKey, columnNames, transactionID);
        }

        /// <summary>
        /// Delete Data object.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int DeleteByPrimaryKey(object primaryKey, string transactionID)
        {
            return this.adapter.DeleteByPrimaryKey(primaryKey, transactionID);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="dataObject">Data object.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateByPrimaryKey(object primaryKey, object dataObject, string transactionID)
        {
            return this.adapter.UpdateByPrimaryKey(primaryKey, dataObject, transactionID);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateByPrimaryKey(object primaryKey, object dataObject, string[] columnNames, string transactionID)
        {
            return this.adapter.UpdateByPrimaryKey(primaryKey, dataObject, columnNames, transactionID);
        }

        /// <summary>
        /// Check data object by primary key.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>If exists then return true, otherwise return false.</returns>
        public virtual bool ExistsByPrimaryKey(object primaryKey, string transactionID)
        {
            return this.adapter.ExistsByPrimaryKey(primaryKey, transactionID);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Data object.</returns>
        public virtual object GetDataByCondition(CommonCommand conditionCommand, string transactionID)
        {
            return this.adapter.GetDataByCondition(conditionCommand, transactionID);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Data object.</returns>
        public virtual object GetDataByCondition(string[] columnNames, CommonCommand conditionCommand, string transactionID)
        {
            return this.adapter.GetDataByCondition(columnNames, conditionCommand, transactionID);
        }

        #region Epxression 
        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Data object.</returns>
        public virtual object GetDataByCondition(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, string transactionID)
        {
            return this.adapter.GetDataByCondition(conditionExpression, transactionID);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Data object.</returns>
        public virtual T GetDataByCondition(string[] columnNames, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, string transactionID)
        {
            return (T)this.adapter.GetDataByCondition(columnNames, conditionExpression, transactionID);
        }

        #region Batch Operation 
        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(conditionExpression, transactionID);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(string[] columnNames, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(columnNames, conditionExpression, transactionID);
        }

        #region Paging Operation 
        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, int startRecord, int maxRecords, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(conditionExpression, startRecord, maxRecords, transactionID);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(string[] columnNames, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, int startRecord, int maxRecords, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(columnNames, conditionExpression, startRecord, maxRecords, transactionID);
        }
        #endregion

        #region 迭代器
        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(conditionExpression, transactionID)) { yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(string[] columnNames, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnNames, conditionExpression, transactionID)) { yield return (T)dataObject; }
        }

        #region Paging Operation 
        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, int startRecord, int maxRecords, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(conditionExpression, startRecord, maxRecords, transactionID)) { yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(string[] columnNames, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, int startRecord, int maxRecords, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnNames, conditionExpression, startRecord, maxRecords, transactionID)) { yield return (T)dataObject; }
        }
        #endregion
        #endregion
        #endregion

        #region column name Epxression 
        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int Fill(object dataObject, object[] primaryKeys, ColumnExpression[] columnExpressions, string transactionID)
        {
            return this.adapter.Fill(dataObject, primaryKeys, columnExpressions, transactionID);
        }

        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">has primary key value Data object.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int Fill(object dataObject, ColumnExpression[] columnExpressions, string transactionID)
        {
            return this.adapter.Fill(dataObject, columnExpressions, transactionID);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>Data object.</returns>
        public virtual T GetData(object[] primaryKeys, ColumnExpression[] columnExpressions, string transactionID)
        {
            return (T)this.adapter.GetData(primaryKeys, columnExpressions, transactionID);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="dataObject">has primary key value Data object.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>Data object.</returns>
        public virtual T GetData(object dataObject, ColumnExpression[] columnExpressions, string transactionID)
        {
            return (T)this.adapter.GetData(dataObject, columnExpressions, transactionID);
        }

        /// <summary>
        /// Insert Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Insert(object dataObject, ColumnExpression[] columnExpressions, string transactionID)
        {
            return this.adapter.Insert(dataObject, columnExpressions, transactionID);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object dataObject, ColumnExpression[] columnExpressions, string transactionID)
        {
            return this.adapter.Update(dataObject, columnExpressions, transactionID);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] primaryKeys, object dataObject, ColumnExpression[] columnExpressions, string transactionID)
        {
            return this.adapter.Update(primaryKeys, dataObject, columnExpressions, transactionID);
        }

        /// <summary>
        /// Save Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Save(object dataObject, ColumnExpression[] columnExpressions, string transactionID)
        {
            return this.adapter.Save(dataObject, columnExpressions, transactionID);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(ColumnExpression[] columnExpressions, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(columnExpressions, transactionID);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(ColumnExpression[] columnExpressions, int startRecord, int maxRecords, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(columnExpressions, startRecord, maxRecords, transactionID);
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(ColumnExpression[] columnExpressions, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnExpressions, transactionID)) { yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(ColumnExpression[] columnExpressions, int startRecord, int maxRecords, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnExpressions, startRecord, maxRecords, transactionID)) { yield return (T)dataObject; }
        }

        /// <summary>
        /// Fill Data object.
        /// </summary>
        /// <param name="dataObject">Data object.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The result of execute command.</returns>
        public virtual int FillByPrimaryKey(object dataObject, object primaryKey, ColumnExpression[] columnExpressions, string transactionID)
        {
            return this.adapter.Fill(dataObject, new object[] { primaryKey }, columnExpressions, transactionID);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>Data object.</returns>
        public virtual T GetDataByPrimaryKey(object primaryKey, ColumnExpression[] columnExpressions, string transactionID)
        {
            return (T)this.adapter.GetData(new object[] { primaryKey }, columnExpressions, transactionID);
        }

        /// <summary>
        /// Update Data object.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="dataObject">Data object.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateByPrimaryKey(object primaryKey, object dataObject, ColumnExpression[] columnExpressions, string transactionID)
        {
            return this.adapter.Update(new object[] { primaryKey }, dataObject, columnExpressions, transactionID);
        }

        /// <summary>
        /// Gets Data object.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>Data object.</returns>
        public virtual T GetDataByCondition(ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, string transactionID)
        {
            return (T)this.adapter.GetDataByCondition(columnExpressions, conditionExpression, transactionID);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(columnExpressions, conditionExpression, transactionID);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>data object column table.</returns>
        public virtual List<T> GetDataList(ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, int startRecord, int maxRecords, string transactionID)
        {
            return (List<T>)this.adapter.GetDataList(columnExpressions, conditionExpression, startRecord, maxRecords, transactionID);
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnExpressions, conditionExpression, transactionID)) { yield return (T)dataObject; }
        }

        /// <summary>
        /// Gets the enumerator of data objects.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>the enumerator of data objects.</returns>
        public virtual IEnumerable<T> GetEnumerator(ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, int startRecord, int maxRecords, string transactionID)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(columnExpressions, conditionExpression, startRecord, maxRecords, transactionID)) { yield return (T)dataObject; }
        }
        #endregion
        #endregion
        #endregion
        #endregion

        public IEnumerable<T> GetEnumerator(System.Data.IDataReader dataReader, System.Collections.IList columnNames, IObjectAccessor objectAccessor, Dictionary<string, DataConverter> propertyConverters, Dictionary<string, string> sourceNames, Dictionary<string, System.Data.DbType> dbTypes)
        {
            try
            {
                while (dataReader.Read())
                {
                    object dataObject = ProcessDataReader(dataReader, columnNames, objectAccessor, propertyConverters, sourceNames, dbTypes);
                    yield return (T)dataObject;
                }
            }
            finally
            {
                if (dataReader != null)
                {
                    dataReader.Close();
                }
            }
        }

        public IEnumerable<T> GetEnumerator(System.Data.IDataReader dataReader, System.Collections.IList columnNames, IDataObjectProxy proxy, Dictionary<string, DataConverter> propertyConverters, Dictionary<string, string> sourceNames, Dictionary<string, System.Data.DbType> dbTypes)
        {
            try
            {
                while (dataReader.Read())
                {
                    object dataObject = ProcessDataReader(dataReader, columnNames, proxy, propertyConverters, sourceNames, dbTypes);
                    yield return (T)dataObject;
                }
            }
            finally
            {
                if (dataReader != null)
                {
                    dataReader.Close();
                }
            }
        }

        private object ProcessDataReader(System.Data.IDataReader dataReader, System.Collections.IList columnNames, IObjectAccessor objectAccessor, Dictionary<string, DataConverter> propertyConverters, Dictionary<string, string> sourceNames, Dictionary<string, System.Data.DbType> dbTypes)
        {
            object dataObject = this.adapter.CreateDataObject();
            if (objectAccessor != null)
            {
                this.adapter.SetDataObjectValues(dataReader, columnNames, objectAccessor, propertyConverters, sourceNames, dbTypes, dataObject);
            }
            else
            {
                // TODO: exception.
                throw new ObjectAccessorException(string.Format("Can't get ObjectAccessor for type [{0}].", DataObjectType));
            }
            return dataObject;
        }

        private object ProcessDataReader(System.Data.IDataReader dataReader, System.Collections.IList columnNames, IDataObjectProxy proxy, Dictionary<string, DataConverter> propertyConverters, Dictionary<string, string> sourceNames, Dictionary<string, System.Data.DbType> dbTypes)
        {
            object dataObject = null;
            if (proxy != null)
            {
                dataObject = proxy.CreateObject();
                this.adapter.SetDataObjectValues(dataReader, columnNames, proxy, propertyConverters, sourceNames, dbTypes, dataObject);
            }
            else
            {
                // TODO: exception.
                throw new ObjectAccessorException(string.Format("Can't get ObjectAccessor for type [{0}].", DataObjectType));
            }
            return dataObject;
        }

        public IEnumerable<T> GetEnumerator(System.Data.IDataReader dataReader, List<string> columnNames, IObjectAccessor objectAccessor, Dictionary<string, DataConverter> propertyConverters, Dictionary<string, string> sourceNames, Dictionary<string, System.Data.DbType> dbTypes, int startRecord, int maxRecords)
        {
            int index = 0;
            int count = 0;
            try
            {
                while ((dataReader.Read()) && (count < maxRecords))
                {
                    if (index >= startRecord)
                    {
                        object dataObject = ProcessDataReader(dataReader, columnNames, objectAccessor, propertyConverters, sourceNames, dbTypes);
                        yield return (T)dataObject;
                        count++;
                    }
                    index++;
                }
            }
            finally
            {
                if (dataReader != null)
                {
                    dataReader.Close();
                }
            }
        }

        public int FillDataObjectList(System.Data.IDataReader dataReader, IList<T> dataObjectList, System.Collections.IList columnNames, IObjectAccessor objectAccessor, Dictionary<string, DataConverter> propertyConverters, Dictionary<string, string> sourceNames, Dictionary<string, System.Data.DbType> dbTypes)
        {
            int index = 0;
            try
            {
                while (dataReader.Read())
                {
                    object dataObject = ProcessDataReader(dataReader, columnNames, objectAccessor, propertyConverters, sourceNames, dbTypes);
                    dataObjectList.Add((T)dataObject);
                    index++;
                }
            }
            finally
            {
                if (dataReader != null)
                {
                    dataReader.Close();
                }
            }
            return index;
        }
        
        public int FillDataObjectList(System.Data.IDataReader dataReader, IList<T> dataObjectList, List<string> columnNames, IObjectAccessor objectAccessor, Dictionary<string, DataConverter> propertyConverters, Dictionary<string, string> sourceNames, Dictionary<string, System.Data.DbType> dbTypes, int startRecord, int maxRecords)
        {
            int index = 0;
            int count = 0;
            try
            {
                while ((dataReader.Read()) && (count < maxRecords))
                {
                    if (index >= startRecord)
                    {
                        object dataObject = ProcessDataReader(dataReader, columnNames, objectAccessor, propertyConverters, sourceNames, dbTypes);
                        dataObjectList.Add((T)dataObject);
                        count++;
                    }
                    index++;
                }
            }
            finally
            {
                if (dataReader != null)
                {
                    dataReader.Close();
                }
            }
            return index;
        }


        public void BuildMappingInfo(System.Data.Common.DataTableMapping dataTableMapping, out List<string> columnNames, out IObjectAccessor objectAccess, out Dictionary<string, DataConverter> propertyConverters, out Dictionary<string, string> sourceNames, out Dictionary<string, System.Data.DbType> dbTypes)
        {
            this.adapter.BuildMappingInfo(dataTableMapping, out columnNames, out objectAccess, out propertyConverters, out sourceNames, out dbTypes);
        }

        public int UpdateByCondition(object dataObject, ConditionExpression condition)
        {
            return this.adapter.UpdateByCondition(dataObject, condition);
        }

        public int UpdateByCondition(object dataObject, CommonCommand conditionCommand)
        {
            return this.adapter.UpdateByCondition(dataObject, conditionCommand);
        }

        public int UpdateByCondition(object dataObject, ColumnExpression[] columns, ConditionExpression condition)
        {
            return this.adapter.UpdateByCondition(dataObject, columns, condition);
        }

        public int UpdateByCondition(object dataObject, ColumnExpression[] columns, CommonCommand conditionCommand)
        {
            return this.adapter.UpdateByCondition(dataObject, columns, conditionCommand);
        }

        public void BuildMappingInfo(System.Data.Common.DataTableMapping dataTableMapping, out List<string> columnNames, IDataObjectProxy proxy, out Dictionary<string, DataConverter> propertyConverters, out Dictionary<string, string> sourceNames, out Dictionary<string, System.Data.DbType> dbTypes)
        {
            this.adapter.BuildMappingInfo(dataTableMapping, out columnNames, proxy, out propertyConverters, out sourceNames, out dbTypes);
        }

        public void BuildMappingInfo(System.Data.Common.DataTableMapping dataTableMapping, out List<string> columnNames, out Dictionary<string, System.Reflection.PropertyInfo> propertyInfos, out Dictionary<string, DataConverter> propertyConverters, out Dictionary<string, string> sourceNames, out Dictionary<string, System.Data.DbType> dbTypes)
        {
            this.adapter.BuildMappingInfo(dataTableMapping, out columnNames, out propertyInfos, out propertyConverters, out sourceNames, out dbTypes);
        }

        public IEnumerable<T> GetEnumerator(System.Data.IDataReader dataReader, List<string> columnNames, Dictionary<string, System.Reflection.PropertyInfo> propertyInfos, Dictionary<string, DataConverter> propertyConverters, Dictionary<string, string> sourceNames, Dictionary<string, System.Data.DbType> dbTypes)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(dataReader, columnNames, propertyInfos, propertyConverters, sourceNames, dbTypes)) { yield return (T)dataObject; }
        }

        public IEnumerable<T> GetEnumerator(System.Data.IDataReader dataReader, List<string> columnNames, Dictionary<string, System.Reflection.PropertyInfo> propertyInfos, Dictionary<string, DataConverter> propertyConverters, Dictionary<string, string> sourceNames, Dictionary<string, System.Data.DbType> dbTypes, int startRecord, int maxRecords)
        {
            foreach (object dataObject in this.adapter.GetEnumerator(dataReader, columnNames, propertyInfos, propertyConverters, sourceNames, dbTypes, startRecord, maxRecords)) { yield return (T)dataObject; }
        }

        public int FillDataObjectList(System.Data.IDataReader dataReader, IList<T> dataObjectList, List<string> columnNames, Dictionary<string, System.Reflection.PropertyInfo> propertyInfos, Dictionary<string, DataConverter> propertyConverters, Dictionary<string, string> sourceNames, Dictionary<string, System.Data.DbType> dbTypes)
        {
            int index = 0;
            try
            {
                while (dataReader.Read())
                {
                    object dataObject = ProcessDataReader(dataReader, columnNames, propertyInfos, propertyConverters, sourceNames, dbTypes);
                    dataObjectList.Add((T)dataObject);
                    index++;
                }
            }
            finally
            {
                if (dataReader != null)
                {
                    dataReader.Close();
                }
            }
            return index;
        }

        public int FillDataObjectList(System.Data.IDataReader dataReader, IList<T> dataObjectList, List<string> columnNames, Dictionary<string, System.Reflection.PropertyInfo> propertyInfos, Dictionary<string, DataConverter> propertyConverters, Dictionary<string, string> sourceNames, Dictionary<string, System.Data.DbType> dbTypes, int startRecord, int maxRecords)
        {
            int index = 0;
            int count = 0;
            try
            {
                while ((dataReader.Read()) && (count < maxRecords))
                {
                    if (index >= startRecord)
                    {
                        object dataObject = ProcessDataReader(dataReader, columnNames, propertyInfos, propertyConverters, sourceNames, dbTypes);
                        dataObjectList.Add((T)dataObject);
                        count++;
                    }
                    index++;
                }
            }
            finally
            {
                if (dataReader != null)
                {
                    dataReader.Close();
                }
            }
            return index;
        }

        private object ProcessDataReader(System.Data.IDataReader dataReader, List<string> columnNames, Dictionary<string, System.Reflection.PropertyInfo> propertyInfos, Dictionary<string, DataConverter> propertyConverters, Dictionary<string, string> sourceNames, Dictionary<string, System.Data.DbType> dbTypes)
        {
            object dataObject = this.adapter.CreateDataObject();
            this.adapter.SetDataObjectValues(dataReader, columnNames, propertyInfos, propertyConverters, sourceNames, dbTypes, dataObject);
            return dataObject;
        }

        #region Bulk operation
        public virtual int Insert(IList<T> dataObjectList)
        {
            return this.adapter.Insert(dataObjectList as System.Collections.IList);
        }

        public virtual int Insert(IList<T> dataObjectList, ColumnExpression[] columnExpressions)
        {
            return this.adapter.Insert(dataObjectList as System.Collections.IList, columnExpressions);
        }

        public virtual int Update(IList<T> dataObjectList)
        {
            return this.adapter.Update(dataObjectList as System.Collections.IList);
        }

        public virtual int Update(IList<T> dataObjectList, ColumnExpression[] columnExpressions)
        {
            return this.adapter.Update(dataObjectList as System.Collections.IList, columnExpressions);
        }

        public virtual int Save(IList<T> dataObjectList)
        {
            return this.adapter.Save(dataObjectList as System.Collections.IList);
        }

        public virtual int Save(IList<T> dataObjectList, ColumnExpression[] columnExpressions)
        {
            return this.adapter.Save(dataObjectList as System.Collections.IList, columnExpressions);
        }


        public virtual int Delete(IList<T> dataObjectList)
        {
            return this.adapter.Delete(dataObjectList as System.Collections.IList);
        }

        public virtual int Exists(IList<T> dataObjectList)
        {
            return this.adapter.Exists(dataObjectList as System.Collections.IList);
        }
        #endregion


        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <returns>data object column table.</returns>
        public virtual IDataReader GetDataReader()
        {
            return (IDataReader)this.adapter.GetDataReader();
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>data object column table.</returns>
        public virtual IDataReader GetDataReader(string[] columnNames)
        {
            return (IDataReader)this.adapter.GetDataReader(columnNames);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>data object column table.</returns>
        public virtual IDataReader GetDataReader(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            return (IDataReader)this.adapter.GetDataReader(conditionExpression);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>data object column table.</returns>
        public virtual IDataReader GetDataReader(string[] columnNames, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            return (IDataReader)this.adapter.GetDataReader(columnNames, conditionExpression);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>data object column table.</returns>
        public virtual IDataReader GetDataReader(ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            return (IDataReader)this.adapter.GetDataReader(columnExpressions, conditionExpression);
        }

        /// <summary>
        /// Gets data object column table.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>data object column table.</returns>
        public virtual IDataReader GetDataReader(ColumnExpression[] columnExpressions)
        {
            return (IDataReader)this.adapter.GetDataReader(columnExpressions);
        }
    }
}
